-
Notifications
You must be signed in to change notification settings - Fork 1.1k
ctest: test ctest-next in ctest-test #4558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
adf53e7
to
bab7d0b
Compare
Unfortunately, I have no idea what the errors mean. |
Can you try updating the templates to change |
bab7d0b
to
5da155d
Compare
Fixes the previous error, but a new one pops up, looks like it's a mix of forgetting to ignore 2024 edition crates for targets that don't support it, and the fact that the old If we want to keep both we'll probably have to keep them separate as they were before. The edition was changed to 2024 since |
0b9618d
to
91d2a6a
Compare
76f4fdb
to
2da67c7
Compare
ctest-next/src/ffi_items.rs
Outdated
let mut link_name_iter = attrs | ||
.iter() | ||
.filter(|attr| attr.path().is_ident("link_name")); | ||
|
||
let link_name = link_name_iter.next().and_then(|attr| match &attr.meta { | ||
syn::Meta::NameValue(nv) => { | ||
if let syn::Expr::Lit(expr_lit) = &nv.value { | ||
if let syn::Lit::Str(lit_str) = &expr_lit.lit { | ||
return Some(lit_str.value().into_boxed_str()); | ||
} | ||
} | ||
None | ||
} | ||
_ => None, | ||
}); | ||
|
||
if let Some(attr) = link_name_iter.next() { | ||
panic!("multiple `#[link_name = ...]` attributes found: {attr:?}"); | ||
} | ||
|
||
link_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified a bit to return early if there is no link_name
:
let link_name = link_name_iter.next()?;
if let Some(attr) = link_name_iter.next() {
panic!("multiple `#[link_name = ...]` attributes found: {attr:?}");
}
if let syn::Meta::NameValue(nv) = &attr.meta
&& let syn::Expr::Lit(expr_lit) = &nv.value
&& let syn::Lit::Str(lit_str) = &expr_lit.lit {
return Some(lit_str.value().into_boxed_str());
}
panic!("unrecognized `link_name` syntax: {attr:?}");
ctest-next/templates/test.rs
Outdated
#[expect(unused_imports)] | ||
use std::{mem, ptr, slice}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be allow
if the imports are unused only for specific expansions, or delete mem
/ptr
/slice
if one of those is always unused.
@@ -17,7 +17,8 @@ typedef struct { | |||
int64_t b; | |||
} T2Union; | |||
|
|||
static void T2a(void) {} | |||
// FIXME(ctest): Cannot be uncommented until tests for functions are implemented in ctest-next. | |||
// static void T2a(void) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the build.rs instead get a .skip_fn(...)
with a FIXME?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately no, the goal of the function ptr check that hasn't been implemented yet is to make sure that the T2a
in the header and the T2a
in the C file point to different items, since T2a
is a complete function, not just a declaration, it counts as unused regardless of being skipped or not.
2da67c7
to
c4ef228
Compare
c4ef228
to
7c678fc
Compare
Description
ctest-next
using the same test crate asctest
.c_char
import).&str
, they can be added back in with separate constants that are skipped byctest-next
if needed.link_name
support for functions and statics, which goes unused right now but will be used when tests for functions and statics are implemented.libc
, asctest-next
cannot resolve it (can be fixed later, although it isn't really necessary anywhere)Sources
Checklist
libc-test/semver
have been updated*LAST
or*MAX
areincluded (see #3131)
cd libc-test && cargo test --target mytarget
);especially relevant for platforms that may not be checked in CI